<?php

namespace app\admin\controller;


use app\admin\service\EquipManageService;

class EquipManage extends Backend
{
    /**
     * @var EquipManageService
     */
    protected $service;

    public function initialize()
    {
        parent::initialize();

        $this->service = new EquipManageService;
        $equipId       = request()->param('equip');
        if ($equipId) {
            $this->service->equipId = $equipId;
        }
    }

    public function get()
    {
        $data = [
            'tree'   => $this->service->tree(),
            'manage' => $this->service->get()
        ];
        $this->jsonReturn(message('success', true, $data));
    }

    public function save()
    {
        $this->service->save(request()->param('manage'));
        $this->jsonReturn(message('success'));
    }
}